﻿Imports System.ComponentModel
Imports System.ComponentModel.Design

<DefaultEvent("GroupSelectEvent")> _
Public Class MobileTypeControl

    Public Sub New()

        ' 此调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        ' 在 InitializeComponent() 调用之后添加任何初始化。
        Init()

    End Sub

    Private Sub Init()
        Me.tb_netid.Text = "1"
        Me.rb_DevTypeBig.Checked = True
        Me.rb_DevTypeSmall.Checked = False


        _groupSelected = False
    End Sub

    Private _dtiItem As DevTypeItem
    <Browsable(False)> _
    Public Property dtiItem() As DevTypeItem
        Get
            getItem()
            If _dtiItem Is Nothing Then
                _dtiItem = New DevTypeItem()
            End If

            Return _dtiItem

        End Get
        Set(ByVal value As DevTypeItem)
            _dtiItem = value
            SetItem(value)
        End Set
    End Property

    Private Sub getItem()
        If _dtiItem Is Nothing Then
            _dtiItem = New DevTypeItem()
        End If

        _dtiItem.NetId = Integer.Parse(Trim(Me.tb_netid.Text))
        _dtiItem.DevType = IIf(Me.rb_DevTypeBig.Checked, 1, 2)
        _dtiItem.ProjectID = txtName.Text

        If _dtiItem.RefNum >= 1 Then
            If _dtiItem.RefTypeGroupList.Count < 1 Then
                _dtiItem.RefTypeGroupList.Add(New RefTypeItem)
            End If
            _dtiItem.RefTypeGroupList.Item(0).RefId = 1

        End If


    End Sub


    Private Sub SetItem(ByVal value As DevTypeItem)
        If value.NetId > 0 And value.NetId <= 256 Then
            Me.tb_netid.Text = value.NetId.ToString
        End If

        If value.DevType = 1 Then
            Me.rb_DevTypeBig.Checked = True
        ElseIf value.DevType = 2 Then
            Me.rb_DevTypeSmall.Checked = True
        Else
            Me.rb_DevTypeBig.Checked = False
            Me.rb_DevTypeSmall.Checked = False
        End If

        Me.txtName.Text = value.ProjectID

    End Sub

    Private Sub CompressorGroupControl_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click
        RaiseEvent GroupSelectEvent(Me, New EventArgs)
    End Sub

    Public Event GroupSelectEvent As EventHandler

    Private _groupSelected As Boolean
    Public Property groupSelected() As Boolean
        Get
            Return _groupSelected
        End Get
        Set(ByVal value As Boolean)
            _groupSelected = value
            Me.gbsel.Visible = value
        End Set
    End Property


    Public Sub SetEnable(ByVal b As Boolean)
        Me.Panel1.Enabled = b
    End Sub

    Public Sub SetNetId(ByVal val As Integer)
        Me.tb_netid.Text = val.ToString()
        If Integer.Parse(Trim(Me.tb_netid.Text)) = 1 Then ' 1号网络设备必须设置为大板类型
            Me.rb_DevTypeBig.Checked = True
            Me.rb_DevTypeSmall.Checked = False
            Me.rb_DevTypeSmall.Enabled = True
        End If

    End Sub

    Private Sub Nud_RefNum_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        
    End Sub

End Class
